
from lxml import etree
import requests

headers= {"User-Agent" : "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1 Trident/5.0;"}
url='https://www.5tps.com/html/23602.html'
html=etree.HTML(requests.get(url,headers=headers).content)

results=html.xpath('//ul/li/a/@title') #音频链接

resultst=html.xpath('//ul/li/a/text()') #章节名字

for i in range(len(results)):

results[i]='http://psf.tt56w.com:8000/单田芳/单田芳_破晓记(37回)/'+results[i]

resultst[i]=resultst[i].replace('\xa0','')

with open('G:\dota\pingshu2\{}.mp3'.format(resultst[i][1:-1]),'wb') as f:

f.write(requests.get(results[i]).content)#下载并保存，具体保存路径根据需要修改

print(resultst[i][1:-1])
print('爬取完成！')